package org.xiji.strategyTwo;

import org.xiji.strategyTwo.book.BookStrategy;
import org.xiji.strategyTwo.book.Impl.ChineseBook;
import org.xiji.strategyTwo.book.Impl.EnglishBook;
import org.xiji.strategyTwo.book.Impl.HistoryBook;
import org.xiji.strategyTwo.book.Impl.MathBook;
import org.xiji.strategyTwo.book.User;

/**
 * 策略模式
 */
public class StrategyTwoMain {
    public static void main(String[] args) {
        User user = new User("小久");

        //如何小久想读英语书，通过策略模式获取英语书
        System.out.println("小久想读英语书");
        String englishBook = new BookStrategy(new EnglishBook()).getBookStrategy();
        user.readBook(englishBook);
        System.out.println("小久想读数学书");
        //如果小久想读数学书，通过策略模式获取数学书
        String mathBook = new BookStrategy(new MathBook()).getBookStrategy();
        user.readBook(mathBook);
        //如果小久想读语文书，可以通过策略模式获取语文书
        System.out.println("小久想读语文书");
        String chineseBook = new BookStrategy(new ChineseBook()).getBookStrategy();
        user.readBook(chineseBook);

        //获取小久想读历史书了
        System.out.println("小久想读历史书");
        String historyBook = new BookStrategy(new HistoryBook()).getBookStrategy();
        user.readBook(historyBook);



    }
}
